<!--
 * @Date: 2022-01-19 10:10:12
 * @LastEditTime: 2022-11-05 09:10:48
-->
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Document</title>
</head>

<body>
  <script>
    // 3. 写法2双重for循环 相当于两个指针进行遍历
    // O(n^2)
    var containsDuplicate = function (nums) {
      for (var i = 0; i < nums.length - 1; i++) {
        for (var j = i + 1; j < nums.length; j++) {
          if (nums[i] === nums[j]) {
            return true
          }
        }
      }
      return false
    }
    console.log(containsDuplicate([1, 2, 2, 3, 3, 5]))
    console.log(containsDuplicate([1, 5]))
  </script>
</body>

</html>